#ifndef _CTERMWINDOW_H_
#define _CTERMWINDOW_H_

#include <buola/gui/cwindow.h>
#include <buola/term/ctermbox.h>

namespace buola {

class CTermWindow;
typedef intrusive_ptr<CTermWindow> PTermWindow;
    
class CTermWindow : public gui::CWindow
{
    struct SPack
    {
    public:
        std::wstring mTitle;
        PTermBox mBox;
        gui::CTabBoxItem *mItem;
    };

public:
    CTermWindow();

protected:
    SPack *NewPack(const std::wstring &pTitle);
    void FillToolBar();
    SPack *GetTerm(gui::CTabBoxItem *pItem);
public:
    void OpenApp(const std::string &pCmd);
    void OpenShell();

protected:
////////////// event handling //////////////
    void OnTab(gui::CTabBoxItem *pItem);
    void OnTitleChanged(SPack*);

public:
    static const PTermWindow &GetTermWindow();

protected:
    gui::PTabBox mTabBox;
    gui::PMenu mMenu;
    gui::PToolBar mToolBar;
    std::vector<std::unique_ptr<SPack>> mTerms;
    SPack *mCurTerm;
};

/*namespace buola*/ }

#endif
